package electricity.controller;

import electricity.dto.DeviceQueryDTO;
import electricity.result.Result;
import electricity.service.FaultService;
import electricity.vo.FaultTypeVo;
import electricity.vo.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/fault")
@Tag(name = "故障分析")
@Slf4j
public class FaultCtroller {
    @Autowired
    private FaultService faultService;

    @GetMapping("/list")
    @Operation(summary = "故障分析列表")
    public Result<PageResult> page(DeviceQueryDTO deviceQueryDTO) {
        log.info("故障深度分析:{}", deviceQueryDTO);
        PageResult pageResult = faultService.pageQuery(deviceQueryDTO);
        return Result.success(pageResult);

    }
    @GetMapping("/typeDistribution")
    @Operation(summary = "故障类型分布")
    public Result<List<FaultTypeVo>> typeDistribution() {
        log.info("故障类型分布");
        List<FaultTypeVo> faultTypeVos = faultService.typeDistribution();
        return Result.success(faultTypeVos);
    }
}
